﻿@page "/StudentProfile"

@inject StudentClient Http
@inject NavigationManager Navigation
@layout StudentLayout

<PageTitle>住宿信息核对</PageTitle>

@if (loading)
{
    <p>Loading...</p>
}
else 
{
    <Modal Title="通知"
           Closable
           Visible="@showNotice"
           OnOk="@(() =>showNotice = false)"
           OnCancel="@(() =>showNotice = false)">
        <p>亲爱的研究生同学：</p>
        <p>为进一步优化和改善研究生住宿环境，准确掌握研究生住宿情况，构建科学精准合理的研究生宿舍网格化管理体系，现对全体在读研究生同学的住宿信息进行核实。</p>
        <p>请每位研究生同学在5月5日-6日按要求填写个人住宿信息，如不及时填写将会影响校园通行授权。</p>
        <p>希望同学们在疫情防控常态化的艰难关头，提高大局意识与政治意识，要身体力行，弘扬清风正气，积极理解、支持各项防疫政策和信息填报。正是因为有我们每个人小我融入“大我”的贡献，才能真正让“动态清零”总方针有效落实，真正让这场人民战、总体战最终胜利！</p>
    </Modal>
    <Breadcrumb Style="margin:2vh;" Separator=">">
		<BreadcrumbItem Href="/login/student">学生登录</BreadcrumbItem>
		<BreadcrumbItem>检查信息</BreadcrumbItem>
    </Breadcrumb>
<Descriptions Style="margin:0 auto;text-align:center;" Title="@($"欢迎，{profile?.Name}")" Bordered Column="@column">
    <DescriptionsItem Title="姓名">@profile?.Name</DescriptionsItem>
    <DescriptionsItem Title="性别">@profile?.Gender</DescriptionsItem>
    <DescriptionsItem Title="学院">@profile?.School</DescriptionsItem>
    <DescriptionsItem Title="年级">@profile?.Grade</DescriptionsItem>
    <DescriptionsItem Title="培养方式">@profile?.CultureMethod</DescriptionsItem>
    <DescriptionsItem Title="专业">@profile?.Major</DescriptionsItem>
</Descriptions>
        <br />
    @switch (profile?.Status)
    {
        case Status.NotCommited:
            <Button OnClick="NavigateToCheck" 
                    Style="background-color: rgb(220,20,60);border-radius:3px;color: white;" 
                    Block>未核对，点击开始核对</Button>
            break;
        case Status.WorkInProgress:
            <Button Style="background-color:rgb(0,191,255);border-radius:3px;" Block>等待审核</Button>
            break;
        case Status.Finished:
            <Button Style="background-color:rgb(90, 220, 90);border-radius:3px;" Block>已完成</Button>
            break;
        case Status.Declined:
            <Button OnClick="NavigateToConfirmCheck"
                    Style="background-color: rgb(220,20,60);border-radius:3px;color: white;" 
                    Block>请求被驳回，点击重新核对</Button>
            break;
    }
}

@code {
    private bool loading = true;
    private Dictionary<string, int> column = new Dictionary<string, int> {
            { "xxl", 3 },
            { "xl", 3},
            { "lg", 2},
            { "md", 2},
            { "sm", 1},
            { "xs", 1}
        };
    private bool showNotice = true;
    private Profile? profile;

    protected async override Task OnInitializedAsync()
    {
        profile = await Http.GetProfile();
        loading = false;
    }

    private void NavigateToCheck()
    {
        Navigation.NavigateTo("/check");
    }
    private void NavigateToConfirmCheck()
    {
        Navigation.NavigateTo("/check/ejIgo25kBo3");
    }
}
